﻿using Microsoft.Practices.Unity;

namespace DllShepherd.SilverlightGoogleMaps.ViewModel
{
    public class ViewModelLocator
    {
        public static IUnityContainer Container
        {
            get;
            private set;
        }

        static ViewModelLocator()
        {
            Container = new UnityContainer();
            Container.RegisterType<MainViewModel>(new ContainerControlledLifetimeManager());
        }

        public MainViewModel Main
        {
            get
            {
                return Container.Resolve<MainViewModel>();
            }
        }

        public static void Cleanup()
        {
            Container.Resolve<MainViewModel>().Cleanup();
        }
    }
}
